﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ATM
{
    public class TransferAccountsState1 : ATMState
    {
        public ATM atm;

        public TransferAccountsState1(ATM atm)
        {
            this.atm = atm;
        }

        public void pressPowerButton()
        {
            return;
        }

        public void pressTakeCashButton()
        {
            return;
        }

        public void pressInsertEnvelopButton()
        {
            return;
        }

        public void pressEnterButton()
        {
            if (this.atm.keypadScreen.Text == "")
            {
                System.Windows.Forms.MessageBox.Show("请输入数字后按Enter键确认!");
                return;
            }

            this.atm.commandString = this.atm.keypadScreen.Text;
            this.atm.commandNumber = Convert.ToInt32(this.atm.commandString);
            this.atm.keypadScreen.Text = "";

            if (this.atm.bankDatabase.balanceInquiry(this.atm.currentAccountID) < this.atm.withdrawal.amount)
            {
                System.Windows.Forms.MessageBox.Show("您的账户余额不足，请重新选择金额");
                this.atm.setState(this.atm.inputWithdrawAmountState);
                this.atm.screen.Text = "请输入转账金额：";
                return;
            }

            this.atm.transferAccounts.amount = this.atm.commandNumber;

            this.atm.setState(this.atm.transferAccountState2);
            this.atm.screen.Text = "请输入要转账到的账号：";
            return;
        }
    }
}
